package test.model;

import m.common.model.FieldMeta;
import m.common.model.Model;
import m.common.model.TableMeta;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;
import m.system.cache.FlushCache;
import m.system.cache.FlushCacheList;

import java.util.List;

@TableMeta(name = "t_school_room", description = "班级")
public class SchoolRoom extends Model implements FlushCache, FlushCacheList {
    @FieldMeta(name="grade",type= FieldType.STRING,length=50,description="年级",dictOption = "1:一年级,2:二年级,3:三年级,4:四年级")
    private String grade;
    public final static String Grade1="1";
    public final static String Grade2="2";
    public final static String Grade3="3";
    public final static String Grade4="4";

    @FieldMeta(name="num",type= FieldType.STRING,length=50,description="编号")
    private String num;
    @FieldMeta(name="name",type= FieldType.STRING,length=50,description="名称")
    private String name;

    public String getNum() {
        return num;
    }

    public void setNum(String num) {
        this.num = num;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    @Override
    public SchoolRoom getCacheModel(String num) throws Exception {
        return ModelQueryList.getModel(SchoolRoom.class,new String[]{"*"},
                QueryCondition.eq("num",num));
    }

    @Override
    public List<SchoolRoom> getCacheList(String grade) throws Exception {
        return ModelQueryList.getModelList(SchoolRoom.class,new String[]{"*"},null,
                QueryCondition.eq("grade",grade));
    }
}
